from django.db import models
from bmhdemo import utils
from django.contrib.auth.models import User
      
class role(models.Model):
    name = models.CharField(max_length=128,null=True)
    parent_id = models.CharField(max_length=64,null=True)
    rights = models.CharField(max_length=256,null=True)
    
    class Meta:
        db_table = 'role'

    def __unicode__(self):
        return self.name
    
class user(models.Model):
    user = models.ForeignKey(User)
    username = models.CharField(max_length=128,null=True)
    password = models.CharField(max_length=64,null=True)
    name = models.CharField(max_length=64,null=True)
    rights = models.CharField(max_length=64,null=True)
    rights_id = models.CharField(max_length=64,null=True)
    last_login = models.DateTimeField(null=True)
    ip = models.CharField(max_length=64,null=True)
    status = models.CharField(max_length=5,choices=utils.MODULES_POWER_STATUS_CHOICES,default=0)
    role = models.ForeignKey(role)
    skin = models.CharField(max_length=64,null=True)
    
    class Meta:
        db_table = 'user'

    def __unicode__(self):
        return self.username
    
class menu(models.Model):
    name = models.CharField(max_length=128,null=True)
    url = models.CharField(max_length=128,null=True)
    parent_id = models.IntegerField()
    order = models.CharField(max_length=64,null=True)
    icon = models.CharField(max_length=64,null=True)
    type = models.CharField(max_length=64,null=True)
    target = models.CharField(max_length=64,null=True)
        
    class Meta:
        db_table = 'menu'

    def __unicode__(self):
        return self.name

